package com.cmcc.fj12580.utils;

import android.content.Context;
import android.graphics.drawable.BitmapDrawable;
import android.view.Gravity;
import android.view.LayoutInflater;
import android.view.View;
import android.view.View.OnClickListener;
import android.view.WindowManager.LayoutParams;
import android.widget.Button;
import android.widget.PopupWindow;

import com.cmcc.fj12580.R;

public abstract class PopupView implements OnClickListener {

	private PopupWindow popupWindow;

	public PopupView(Context context) {
		View view = LayoutInflater.from(context).inflate(R.layout.population, null);
		((Button) view.findViewById(R.id.pop_weibo)).setOnClickListener(this);
		((Button) view.findViewById(R.id.pop_mail)).setOnClickListener(this);
		((Button) view.findViewById(R.id.pop_sme)).setOnClickListener(this);
		((Button) view.findViewById(R.id.pop_cancel)).setOnClickListener(this);

		popupWindow = new PopupWindow(view, LayoutParams.FILL_PARENT, LayoutParams.WRAP_CONTENT, true);
		// popupWindow.setAnimationStyle(R.style.PopupAnimation);
		popupWindow.setBackgroundDrawable(new BitmapDrawable());
		popupWindow.setFocusable(true);
	}

	public void showPop(View v) {
		popupWindow.showAtLocation(v, Gravity.BOTTOM, 0, 0);
	}

	@Override
	public void onClick(View arg0) {
		switch (arg0.getId()) {
		case R.id.pop_weibo:
			popWeibo();
			popupWindow.dismiss();
			break;
		case R.id.pop_mail:
			popMail();
			popupWindow.dismiss();
			break;
		case R.id.pop_sme:
			popEms();
			popupWindow.dismiss();
			break;
		case R.id.pop_cancel:
			popupWindow.dismiss();
			break;
		}
	}

	public abstract void popWeibo();

	public abstract void popMail();

	public abstract void popEms();
}
